DROP TABLE IF EXISTS jms_dm.dm_customer_loss_warning_week_w ;
CREATE EXTERNAL TABLE `jms_dm.dm_customer_loss_warning_week_w`(
  `date_type` string COMMENT '日期类型 day/week/month',
  `network_level` string COMMENT '统计维度：agent/fran/network',
  `date_time` string COMMENT '数据2021-48',
  `monday_date` string COMMENT '每周的第一天:2021-48 对应2021-12-29',
  `agent_name` string COMMENT '代理区名称',
  `agent_code` string COMMENT '代理区编码',
  `fran_name` string COMMENT '加盟商编码',
  `fran_code` string COMMENT '加盟商编码',
  `network_name` string COMMENT '网点名称',
  `network_code` string COMMENT '网点编码',
  `customer_level` string COMMENT '客户等级',
  `customer_cnt` int COMMENT '客户总数',
  `loss_customer_cnt` int COMMENT '流失客户',
  `loss_customer_ticket_qty` int COMMENT '流失客户发货数量',
  `loss_customer_rt` decimal(16,4) COMMENT '客户流失率',
  `save_customer_cnt` int COMMENT '挽回客户',
  `save_customer_ticket_qty` int COMMENT '挽回客户发货数量',
  `save_customer_rt` decimal(16,4) COMMENT '客户挽回率',
  `new_customer_cnt` int COMMENT '新签客户数',
  `new_customer_ticket_qty` int COMMENT '新签客户发货量',
  `new_customer_rt` decimal(16,4) COMMENT '新客户占比',
  `warning_customer_cnt` int COMMENT '预警客户数',
  `warning_customer_ticket_qty` int COMMENT '预警客户发货量',
  `warning_customer_cnt_up` int COMMENT '上一查询时间维度预警客户个数',
  `warning_customer_cnt_ring_rt` decimal(16,4) COMMENT '预警客户数环比')
COMMENT '客户流失及预警报表_周维度报表'
PARTITIONED BY (
  `wt` string COMMENT '周分区 2021-48',
  `net_level` string COMMENT '网点类型network,fran,agent')
STORED AS PARQUET
LOCATION '/dw/hive/jms_dm.db/external/dm_customer_loss_warning_week_w'
TBLPROPERTIES (
'discover.partitions' = 'false',
'parquet.column.index.access' = 'true'
);